﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Telerik.Windows.Controls;
using Farmacie.Controls;
using Farmacie.Windows;
using Farmacie.Managers;

namespace Farmacie
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            StyleManager.ApplicationTheme = new Office_BlackTheme();

            InitializeComponent();
            this.Loaded += MainWindow_Loaded;

            MainViewModel model = new MainViewModel();
            model.ControlVanzare = controlVanzare;
            model.ControlMedicamente = controlMedicamente;
            model.ControlArhiva = controlArhiva;
            model.ControlStocCritic = controlStocCritic;
            model.ControlRaportVanzari = controlRaportVanzari;
            model.ControlComenzi = controlComenzi;
            model.DetaliiChitante = detaliiChitante;

            this.DataContext = model;
            
            AuthenticationManager.Instance.LoggedUserChanged += new EventHandler(AuthenticationManager_LoggedUserChanged);
        }

        void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            ShowLoginWindow();
            IncasariManager.Instance.ReseteazaCasa(0);
        }

        void AuthenticationManager_LoggedUserChanged(object sender, EventArgs e)
        {
            gridMainContent.Visibility = AuthenticationManager.Instance.IsLoggedIn ? Visibility.Visible : Visibility.Hidden;
        }

        private void ShowLoginWindow()
        {
            LogIn logInWindow = new LogIn();
            logInWindow.ShowDialog();
        }
    }
}
